import bianliang from "./bianliang.js";
import Bullet from "./Bullet.js";
class Hero {
	constructor() {
		this.x = 200; 
		this.y = 500; 
		this.img = bianliang.resObj[1]; 
		this.width = this.img.width / 2;
		this.height = this.img.height / 2;
		this.isTwo = false;
	}
	draw(ctx) {
		ctx.drawImage(this.img, this.x, this.y, this.width, this.height);
	}
	fire() {
		if (this.isTwo == false) {
			var b = new Bullet(this.x, this.y);
			b.x = b.x + this.width / 2 - b.width / 2;
			bianliang.bulletList.push(b);
		} else {
			var b_left = new Bullet(this.x, this.y);
			b_left.x = b_left.x + this.width / 4 - b_left.width / 2;
			var b_right = new Bullet(this.x, this.y);
			b_right.x = b_right.x + this.width / 4 * 3 - b_right.width / 2;
			bianliang.bulletList.push(b_left);
			bianliang.bulletList.push(b_right);
		}
	}
}
export default Hero;
